package com.ean.backpack.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ean.backpack.domain.Activepropertylist;
import com.ean.backpack.repository.ActivepropertylistRepository;
import com.ean.backpack.service.ActivepropertylistService;

@Service
@Transactional
public class ActivepropertylistServiceImpl implements ActivepropertylistService {

	@Autowired
	ActivepropertylistRepository activepropertylistRepository;

	public long countAllActivepropertylists() {
		return activepropertylistRepository.count();
	}

	public void deleteActivepropertylist(Activepropertylist activepropertylist) {
		activepropertylistRepository.delete(activepropertylist);
	}

	public Activepropertylist findActivepropertylist(Integer id) {
		return activepropertylistRepository.findOne(id);
	}

	public List<Activepropertylist> findAllActivepropertylists() {
		return activepropertylistRepository.findAll();
	}

	public List<Activepropertylist> findActivepropertylistEntries(
			int firstResult, int maxResults) {
		return activepropertylistRepository.findAll(
				new org.springframework.data.domain.PageRequest(firstResult
						/ maxResults, maxResults)).getContent();
	}

	public void saveActivepropertylist(Activepropertylist activepropertylist) {
		activepropertylistRepository.save(activepropertylist);
	}

	public Activepropertylist updateActivepropertylist(
			Activepropertylist activepropertylist) {
		return activepropertylistRepository.save(activepropertylist);
	}

	@Override
	public List<Activepropertylist> findByCityContainingAndCountryContaining(String city, String country, Pageable pageable) {
		return activepropertylistRepository.findDistinctByCityContainingAndCountryContaining(city, country, pageable);
	}

	@Override
	public List<Activepropertylist> findByCityContainingAndCountryContainingAndStateProvinceContaining(String city, String country, String state, Pageable pageable) {
		return activepropertylistRepository.findDistinctByCityContainingAndCountryContainingAndStateProvinceContaining(city, country, state, pageable);
	}

	@Override
	public List<Activepropertylist> findByCityContaining(String city, Pageable pageable) {
		return activepropertylistRepository.findDistinctByCityContaining(city, pageable);
	}

	@Override
	public List<String> findByCity(String city, String country, String state) {
		return activepropertylistRepository.findByCity(city, country, state);
	}
}
